package com.longcai.piaojia.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.longcai.piaojia.R;
import com.zcx.helper.bound.BoundView;
import com.zcx.helper.bound.BoundViewHelper;
import com.zcx.helper.scale.ScaleScreenHelperFactory;

import java.util.List;

/**
 * Created by Administrator on 2017/1/5.
 */
public class VenueAdapter extends ArrayAdapter<String> {

    private Context context;
    private LayoutInflater layoutInflater;

    public VenueAdapter(Context context, List<String> lists) {
        super(context, 0, lists);

        layoutInflater = LayoutInflater.from(context);

        this.context = context;

    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder viewHolder;

        if (convertView == null) {

            convertView = BoundViewHelper.boundView(viewHolder = new ViewHolder(), ScaleScreenHelperFactory.getInstance().loadView((ViewGroup) layoutInflater.inflate(R.layout.item_venue_list, null)));

            convertView.setTag(viewHolder);

        } else {

            viewHolder = (ViewHolder) convertView.getTag();

        }

        if (position == 1 || position == 0) {

            viewHolder.venue_list_top_tv.setVisibility(View.VISIBLE);

        } else {

            viewHolder.venue_list_top_tv.setVisibility(View.GONE);

        }

        return convertView;
    }

    class ViewHolder {

        @BoundView(R.id.venue_list_top_tv) private TextView venue_list_top_tv;
        @BoundView(R.id.venue_list_iv) private ImageView venue_list_iv;
        @BoundView(R.id.venue_list_venue_name_tv) private TextView venue_list_venue_name_tv;
        @BoundView(R.id.venue_list_address_tv) private TextView venue_list_address_tv;
        @BoundView(R.id.venue_list_bus_tv) private TextView venue_list_bus_tv;

    }
}
